package stack

import "fmt"

type stack struct {
	top  int
	data [20]int
}

func NewStack() *stack {
	return &stack{
		top: -1,
	}
}
func (a *stack) Push(item int) {
	a.top++
	a.data[a.top] = item
}
func (a *stack) Pop() int {
	t := a.data[a.top]
	a.top--
	return t
}
func (a *stack) IsEmpty() bool {
	return a.top == -1
}
func (a *stack) Peek() int {
	return a.data[a.top]
}
func (a *stack) PrintStack() {
	for i := a.top; i >= 0; i-- {
		fmt.Printf("stack[%d]=[%d]\n", i, a.data[i])
	}
}
